var login_page_map = {
		"LOGIN" : { container_div : "login_div", header : "Login" },
		"REGISTER" : { container_div : "registration_div", header : "Register" }
};

function u_show_loginMainDiv(){
	page_map = login_page_map;
	tn_takeToPage("LOGIN");
	document.getElementById('errorTextPlaceHolder').style.display='none';
}

function lg_dologin(){
	var login_data = {
			username : dwr.util.getValue('input_1'),
		    password : dwr.util.getValue('input_3')
		};
	
	var dwrCallMetaData = {
			callback : submit_login,
			exceptionHandler : exception_generic_handler,
			timeout : 100000,
			errorHandler : exception_generic_handler
		};

	DWR_Validation.validateLoginData(login_data, dwrCallMetaData);
}

function submit_login(dwrresp)	{
	if(dwrresp && dwrresp.respCode == 0 && dwrresp.objRespOrError == 'SUCCESS'){
		var loginForm = document.getElementById('login_form');
		var pref = dwr.util.getValue('viewPreference');
		if(pref == 'supplier'){
			loginForm.action = '/login';
		}else{
			loginForm.action = '/login';
		}
		loginForm.submit();
	}else{
		dwr.util.setValue('errorTextPlaceHolder',dwrresp.objRespOrError);
		document.getElementById('errorTextPlaceHolder').style.display='';
	}
}
